package cn.tedu.web;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * Servlet implementation class GetSessionServlet
 */
public class GetSessionServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		HttpSession session=request.getSession();
		//getAttribute从Session对象中读取以保存的信息msg
		//如果灭有其他Servlet保存过的信息,或者session
		//对象是新创建的对象,则返回null
		String msg=(String)session.getAttribute("msg");
		System.out.println("sid:"+session.getId()+",msg"+msg);
		response.setContentType("text/html;charset=utf-8");
		response.getWriter().println("get ok");
	}

}
